﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using STT.Business;
using STT.Entities;
using System.Data;

namespace STT.Admin.UserControls
{
    public partial class ucTimKiemGiangVien : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Methods.ChucVu(ref ddChucVu);
            Methods.ChuyenMon(ref ddChuyenMon);
            Methods.DonVi(ref ddDonVi);
            Methods.NgoaiNgu(ref ddTrinhDoNgoaiNgu);
            Methods.MonHoc(ref ddMonHoc);
            Methods.HocVan(ref ddHocVan);
            Methods.Lop(ref ddLopHoc);
        }

        protected void lbXuatDuLieu_Click(object sender, EventArgs e)
        {

        }

        protected void btTimKiem_Click(object sender, EventArgs e)
        {
            LoadDuLieu();
        }

        protected void gvGiangVien_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvGiangVien.SelectedIndex = e.NewPageIndex;

            LoadDuLieu();
        }

        void LoadDuLieu()
        {
            gvGiangVien.DataSource = BTbGiangVien.SelectTeachersBySearch(new ETbGiangVien
            {
                MaGV = txtMaGiangVien.Text != "" ? int.Parse(txtMaGiangVien.Text) : -1,
                TenGV = txtTenGiangVien.Text,
                MaDonVi = int.Parse(ddDonVi.SelectedValue.ToString()),
                MaChucVu = int.Parse(ddChucVu.SelectedValue.ToString()),
                MaTDChuyenMon = int.Parse(ddChuyenMon.SelectedValue.ToString()),
                MaTDHocVan = int.Parse(ddHocVan.SelectedValue.ToString()),
            }, int.Parse(ddMonHoc.SelectedValue.ToString()),
            txtSoKhoaHocDay.Text != "" ? int.Parse(txtSoKhoaHocDay.Text) : -1,
            int.Parse(ddTrinhDoNgoaiNgu.SelectedValue.ToString()),
            int.Parse(ddLopHoc.SelectedValue.ToString())
            );

            //ScriptManager.RegisterClientScriptBlock(this, GetType(), "Thông báo!", "<script>alert('"+DBNull.Value+"')</script>", false);

            gvGiangVien.DataBind();
        }
    }
}